package com.xzc.datastruc.ujava.c06._0;

public class MyContainer {
    Object[] items = new Object[5];
    int size = 0;

    public MyContainerIterator iterator() {
        return new MyContainerIterator(this);
    }

    public boolean add(Object x) {
        if (items.length == size) {
            Object[] old = items;
            items = new Object[items.length * 2 + 1];
            for (int i = 0; i < size; i++)
                items[i] = old[i];
        }
        items[size++] = x;
        return true;
    }
}
